let ResponseUtils = require("../utils/ResponseUtils");
let StoreService = require("../service/store");

/**
 * 城市控制器
 */
class StoreController {
    static async index(ctx) {
        let result = await StoreService.list(ctx.query.page);
        ctx.body = ResponseUtils.builder(result).success().build();
    }

    static async list(ctx) {
        let result = await StoreService.list(ctx.query.page);
        ctx.body = ResponseUtils.builder(result).success().build();
    }
    static async list1(ctx) {
        let result = await StoreService.list1(ctx.params.cityId);
        ctx.body = ResponseUtils.builder(result).success().build();
    }
    static async detail(ctx) {
        let result = await StoreService.detail(ctx.params.storeId);
        ctx.body = ResponseUtils.builder(result).success().build();
    }

    static async create(ctx) {
        let result = await StoreService.create(ctx.request.body);
        ctx.body = ResponseUtils.builder(result).success().build();
    }
    static async update(ctx) {
        let result = await StoreService.create(ctx.request.body);
        ctx.body = ResponseUtils.builder(result).success().build();
    }

    static async delete(ctx) {
        let id = ctx.params.id;
        let result = await StoreService.delete(id);
        ctx.body = ResponseUtils.builder(result).success().build();
    }
}

module.exports = StoreController;
